package day03;

import java.util.Objects;

public class Card implements Comparable<Card> {

    private int point;
    private String color;
    private int weight;

    public Card(int point, String color) {
        this.point = point;
        this.color = color;
    }

    @Override
    public String toString() {
        return color+point;
    }

    public int getPoint() {
        return point;
    }

    public void setPoint(int point) {
        this.point = point;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return point == card.point &&
                weight == card.weight &&
                Objects.equals(color, card.color);
    }

    @Override
    public int hashCode() {
        return Objects.hash(point, color, weight);
    }

    @Override
    public int compareTo(Card card) {
        if (card.getPoint() > point) {
            return 1;
        } else if (card.getPoint() == point) {
            if (card.getWeight() > weight) {
                return 1;
            }
            return -1;
        }
        return -1;
    }
}
